import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', () => {
  const userInfo = ref({})
  const sk = ref('')

  function setUserInfo(user) {
    userInfo.value = user
  }

  function setSk(token) {
    sk.value = token
  }

  return { userInfo, setUserInfo, sk, setSk }
}, {
  persist: {
    key: 'user',
    storage: localStorage,
    paths: ['userInfo', 'sk']
  }
})
